package com.cleaningcloud.cld.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.cld.domain.CldRestbreaksCalendar;
import com.cleaningcloud.cld.service.ICldRestbreaksCalendarService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 排休日历Controller
 *
 * @author cleaningcloud
 * @date 2024-11-08
 */
@RestController
@RequestMapping("/calendar")
public class CldRestbreaksCalendarController extends BaseController
{
    @Autowired
    private ICldRestbreaksCalendarService cldRestbreaksCalendarService;

    /**
     * 查询排休日历列表
     */
    @RequiresPermissions("cld:calendar:list")
    @GetMapping("/list")
    public TableDataInfo list(CldRestbreaksCalendar cldRestbreaksCalendar)
    {
        startPage();
        List<CldRestbreaksCalendar> list = cldRestbreaksCalendarService.selectCldRestbreaksCalendarList(cldRestbreaksCalendar);
        return getDataTable(list);
    }

    /**
     * 导出排休日历列表
     */
    @RequiresPermissions("cld:calendar:export")
    @Log(title = "排休日历", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CldRestbreaksCalendar cldRestbreaksCalendar)
    {
        List<CldRestbreaksCalendar> list = cldRestbreaksCalendarService.selectCldRestbreaksCalendarList(cldRestbreaksCalendar);
        ExcelUtil<CldRestbreaksCalendar> util = new ExcelUtil<CldRestbreaksCalendar>(CldRestbreaksCalendar.class);
        util.exportExcel(response, list, "排休日历数据");
    }

    /**
     * 获取排休日历详细信息
     */
    @RequiresPermissions("cld:calendar:query")
    @GetMapping(value = "/{restbreakCalendarId}")
    public AjaxResult getInfo(@PathVariable("restbreakCalendarId") Long restbreakCalendarId)
    {
        return success(cldRestbreaksCalendarService.selectCldRestbreaksCalendarByRestbreakCalendarId(restbreakCalendarId));
    }

    /**
     * 新增排休日历
     */
    @RequiresPermissions("cld:calendar:add")
    @Log(title = "排休日历", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldRestbreaksCalendar cldRestbreaksCalendar)
    {
        return toAjax(cldRestbreaksCalendarService.insertCldRestbreaksCalendar(cldRestbreaksCalendar));
    }

    /**
     * 修改排休日历
     */
    @RequiresPermissions("cld:calendar:edit")
    @Log(title = "排休日历", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldRestbreaksCalendar cldRestbreaksCalendar)
    {
        return toAjax(cldRestbreaksCalendarService.updateCldRestbreaksCalendar(cldRestbreaksCalendar));
    }

    /**
     * 删除排休日历
     */
    @RequiresPermissions("cld:calendar:remove")
    @Log(title = "排休日历", businessType = BusinessType.DELETE)
    @DeleteMapping("/{restbreakCalendarIds}")
    public AjaxResult remove(@PathVariable Long[] restbreakCalendarIds)
    {
        return toAjax(cldRestbreaksCalendarService.deleteCldRestbreaksCalendarByRestbreakCalendarIds(restbreakCalendarIds));
    }
}
